.class public final Llt/noframe/gpsfarmguide/purchases/NavigatorBillingHandler;
.super Ljava/lang/Object;
.source "NavigatorBillingHandler.kt"

# interfaces
.implements Lcom/android/billingclient/api/PurchasesUpdatedListener;
.implements Lcom/android/billingclient/api/BillingClientStateListener;


# annotations
.annotation system Ldalvik/annotation/SourceDebugExtension;
    value = "SMAP\nNavigatorBillingHandler.kt\nKotlin\n*S Kotlin\n*F\n+ 1 NavigatorBillingHandler.kt\nlt/noframe/gpsfarmguide/purchases/NavigatorBillingHandler\n+ 2 _Collections.kt\nkotlin/collections/CollectionsKt___CollectionsKt\n*L\n1#1,157:1\n1582#2,2:158\n*E\n*S KotlinDebug\n*F\n+ 1 NavigatorBillingHandler.kt\nlt/noframe/gpsfarmguide/purchases/NavigatorBillingHandler\n*L\n71#1,2:158\n*E\n"
.end annotation


# instance fields
.field private final activity:Llt/noframe/gpsfarmguide/views/ActivityDrawer;

.field public mBillingClient:Lcom/android/billingclient/api/BillingClient;

.field private final mBindToActivityCycle:Ljava/util/concurrent/atomic/AtomicBoolean;

.field private mConnecting:Z

.field private final pendingRequests:Ljava/util/concurrent/ArrayBlockingQueue;
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "Ljava/util/concurrent/ArrayBlockingQueue<",
            "Lkotlin/jvm/functions/Function0<",
            "Lkotlin/Unit;",
            ">;>;"
        }
    .end annotation
.end field


# direct methods
.method public constructor <init>(Llt/noframe/gpsfarmguide/views/ActivityDrawer;)V
    .locals 1

    const-string v0, "activity"

    invoke-static {p1, v0}, Lkotlin/jvm/internal/Intrinsics;->checkParameterIsNotNull(Ljava/lang/Object;Ljava/lang/String;)V

    .line 13
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    iput-object p1, p0, Llt/noframe/gpsfarmguide/purchases/NavigatorBillingHandler;->activity:Llt/noframe/gpsfarmguide/views/ActivityDrawer;

    .line 18
    new-instance p1, Ljava/util/concurrent/ArrayBlockingQueue;

    const/16 v0, 0x1e

    invoke-direct {p1, v0}, Ljava/util/concurrent/ArrayBlockingQueue;-><init>(I)V

    iput-object p1, p0, Llt/noframe/gpsfarmguide/purchases/NavigatorBillingHandler;->pendingRequests:Ljava/util/concurrent/ArrayBlockingQueue;

    .line 24
    new-instance p1, Ljava/util/concurrent/atomic/AtomicBoolean;

    const/4 v0, 0x0

    invoke-direct {p1, v0}, Ljava/util/concurrent/atomic/AtomicBoolean;-><init>(Z)V

    iput-object p1, p0, Llt/noframe/gpsfarmguide/purchases/NavigatorBillingHandler;->mBindToActivityCycle:Ljava/util/concurrent/atomic/AtomicBoolean;

    return-void
.end method

.method private final makeConnectedRequest(Lkotlin/jvm/functions/Function0;)V
    .locals 1
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "(",
            "Lkotlin/jvm/functions/Function0<",
            "Lkotlin/Unit;",
            ">;)V"
        }
    .end annotation

    .line 134
    iget-object v0, p0, Llt/noframe/gpsfarmguide/purchases/NavigatorBillingHandler;->pendingRequests:Ljava/util/concurrent/ArrayBlockingQueue;

    invoke-virtual {v0, p1}, Ljava/util/concurrent/ArrayBlockingQueue;->offer(Ljava/lang/Object;)Z

    .line 135
    invoke-direct {p0}, Llt/noframe/gpsfarmguide/purchases/NavigatorBillingHandler;->validateAndExecuteQueue()V

    return-void
.end method

.method private final validateAndExecuteQueue()V
    .locals 4

    .line 142
    iget-object v0, p0, Llt/noframe/gpsfarmguide/purchases/NavigatorBillingHandler;->pendingRequests:Ljava/util/concurrent/ArrayBlockingQueue;

    invoke-interface {v0}, Ljava/util/Collection;->isEmpty()Z

    move-result v0

    const/4 v1, 0x1

    xor-int/2addr v0, v1

    if-eqz v0, :cond_5

    .line 144
    :cond_0
    iget-object v0, p0, Llt/noframe/gpsfarmguide/purchases/NavigatorBillingHandler;->mBillingClient:Lcom/android/billingclient/api/BillingClient;

    const/4 v2, 0x0

    const-string v3, "mBillingClient"

    if-eqz v0, :cond_4

    invoke-virtual {v0}, Lcom/android/billingclient/api/BillingClient;->isReady()Z

    move-result v0

    if-nez v0, :cond_3

    .line 145
    iget-boolean v0, p0, Llt/noframe/gpsfarmguide/purchases/NavigatorBillingHandler;->mConnecting:Z

    if-nez v0, :cond_2

    .line 146
    iget-object v0, p0, Llt/noframe/gpsfarmguide/purchases/NavigatorBillingHandler;->mBillingClient:Lcom/android/billingclient/api/BillingClient;

    if-eqz v0, :cond_1

    invoke-virtual {v0, p0}, Lcom/android/billingclient/api/BillingClient;->startConnection(Lcom/android/billingclient/api/BillingClientStateListener;)V

    .line 147
    iput-boolean v1, p0, Llt/noframe/gpsfarmguide/purchases/NavigatorBillingHandler;->mConnecting:Z

    goto :goto_0

    .line 146
    :cond_1
    invoke-static {v3}, Lkotlin/jvm/internal/Intrinsics;->throwUninitializedPropertyAccessException(Ljava/lang/String;)V

    throw v2

    :cond_2
    :goto_0
    return-void

    .line 151
    :cond_3
    iget-object v0, p0, Llt/noframe/gpsfarmguide/purchases/NavigatorBillingHandler;->pendingRequests:Ljava/util/concurrent/ArrayBlockingQueue;

    invoke-virtual {v0}, Ljava/util/concurrent/ArrayBlockingQueue;->poll()Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Lkotlin/jvm/functions/Function0;

    invoke-interface {v0}, Lkotlin/jvm/functions/Function0;->invoke()Ljava/lang/Object;

    .line 153
    iget-object v0, p0, Llt/noframe/gpsfarmguide/purchases/NavigatorBillingHandler;->pendingRequests:Ljava/util/concurrent/ArrayBlockingQueue;

    invoke-interface {v0}, Ljava/util/Collection;->isEmpty()Z

    move-result v0

    xor-int/2addr v0, v1

    if-nez v0, :cond_0

    goto :goto_1

    .line 144
    :cond_4
    invoke-static {v3}, Lkotlin/jvm/internal/Intrinsics;->throwUninitializedPropertyAccessException(Ljava/lang/String;)V

    throw v2

    :cond_5
    :goto_1
    return-void
.end method


# virtual methods
.method public final buyRemoveAds()V
    .locals 1

    .line 118
    new-instance v0, Llt/noframe/gpsfarmguide/purchases/NavigatorBillingHandler$buyRemoveAds$1;

    invoke-direct {v0, p0}, Llt/noframe/gpsfarmguide/purchases/NavigatorBillingHandler$buyRemoveAds$1;-><init>(Llt/noframe/gpsfarmguide/purchases/NavigatorBillingHandler;)V

    invoke-direct {p0, v0}, Llt/noframe/gpsfarmguide/purchases/NavigatorBillingHandler;->makeConnectedRequest(Lkotlin/jvm/functions/Function0;)V

    return-void
.end method

.method public final getActivity()Llt/noframe/gpsfarmguide/views/ActivityDrawer;
    .locals 1

    .line 13
    iget-object v0, p0, Llt/noframe/gpsfarmguide/purchases/NavigatorBillingHandler;->activity:Llt/noframe/gpsfarmguide/views/ActivityDrawer;

    return-object v0
.end method

.method public final getMBillingClient()Lcom/android/billingclient/api/BillingClient;
    .locals 1

    .line 15
    iget-object v0, p0, Llt/noframe/gpsfarmguide/purchases/NavigatorBillingHandler;->mBillingClient:Lcom/android/billingclient/api/BillingClient;

    if-eqz v0, :cond_0

    return-object v0

    :cond_0
    const-string v0, "mBillingClient"

    invoke-static {v0}, Lkotlin/jvm/internal/Intrinsics;->throwUninitializedPropertyAccessException(Ljava/lang/String;)V

    const/4 v0, 0x0

    throw v0
.end method

.method public final getPurchasedItems(Lkotlin/jvm/functions/Function1;)V
    .locals 1
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "(",
            "Lkotlin/jvm/functions/Function1<",
            "-",
            "Ljava/util/List<",
            "+",
            "Lcom/android/billingclient/api/Purchase;",
            ">;",
            "Lkotlin/Unit;",
            ">;)V"
        }
    .end annotation

    const-string v0, "activeSubscriptionsListener"

    invoke-static {p1, v0}, Lkotlin/jvm/internal/Intrinsics;->checkParameterIsNotNull(Ljava/lang/Object;Ljava/lang/String;)V

    .line 110
    new-instance v0, Llt/noframe/gpsfarmguide/purchases/NavigatorBillingHandler$getPurchasedItems$1;

    invoke-direct {v0, p0, p1}, Llt/noframe/gpsfarmguide/purchases/NavigatorBillingHandler$getPurchasedItems$1;-><init>(Llt/noframe/gpsfarmguide/purchases/NavigatorBillingHandler;Lkotlin/jvm/functions/Function1;)V

    invoke-direct {p0, v0}, Llt/noframe/gpsfarmguide/purchases/NavigatorBillingHandler;->makeConnectedRequest(Lkotlin/jvm/functions/Function0;)V

    return-void
.end method

.method public onBillingServiceDisconnected()V
    .locals 1

    const/4 v0, 0x0

    .line 89
    iput-boolean v0, p0, Llt/noframe/gpsfarmguide/purchases/NavigatorBillingHandler;->mConnecting:Z

    return-void
.end method

.method public onBillingSetupFinished(I)V
    .locals 1

    const/4 v0, 0x0

    .line 93
    iput-boolean v0, p0, Llt/noframe/gpsfarmguide/purchases/NavigatorBillingHandler;->mConnecting:Z

    if-nez p1, :cond_0

    .line 96
    invoke-direct {p0}, Llt/noframe/gpsfarmguide/purchases/NavigatorBillingHandler;->validateAndExecuteQueue()V

    .line 99
    :cond_0
    new-instance p1, Llt/noframe/gpsfarmguide/purchases/NavigatorBillingHandler$onBillingSetupFinished$1;

    invoke-direct {p1, p0}, Llt/noframe/gpsfarmguide/purchases/NavigatorBillingHandler$onBillingSetupFinished$1;-><init>(Llt/noframe/gpsfarmguide/purchases/NavigatorBillingHandler;)V

    invoke-virtual {p0, p1}, Llt/noframe/gpsfarmguide/purchases/NavigatorBillingHandler;->getPurchasedItems(Lkotlin/jvm/functions/Function1;)V

    return-void
.end method

.method public final onCreate()V
    .locals 2

    .line 29
    iget-object v0, p0, Llt/noframe/gpsfarmguide/purchases/NavigatorBillingHandler;->activity:Llt/noframe/gpsfarmguide/views/ActivityDrawer;

    invoke-static {v0}, Lcom/android/billingclient/api/BillingClient;->newBuilder(Landroid/content/Context;)Lcom/android/billingclient/api/BillingClient$Builder;

    move-result-object v0

    invoke-virtual {v0, p0}, Lcom/android/billingclient/api/BillingClient$Builder;->setListener(Lcom/android/billingclient/api/PurchasesUpdatedListener;)Lcom/android/billingclient/api/BillingClient$Builder;

    invoke-virtual {v0}, Lcom/android/billingclient/api/BillingClient$Builder;->build()Lcom/android/billingclient/api/BillingClient;

    move-result-object v0

    const-string v1, "BillingClient.newBuilder\u2026setListener(this).build()"

    invoke-static {v0, v1}, Lkotlin/jvm/internal/Intrinsics;->checkExpressionValueIsNotNull(Ljava/lang/Object;Ljava/lang/String;)V

    iput-object v0, p0, Llt/noframe/gpsfarmguide/purchases/NavigatorBillingHandler;->mBillingClient:Lcom/android/billingclient/api/BillingClient;

    .line 30
    iget-object v0, p0, Llt/noframe/gpsfarmguide/purchases/NavigatorBillingHandler;->mBindToActivityCycle:Ljava/util/concurrent/atomic/AtomicBoolean;

    const/4 v1, 0x1

    invoke-virtual {v0, v1}, Ljava/util/concurrent/atomic/AtomicBoolean;->set(Z)V

    .line 31
    iget-object v0, p0, Llt/noframe/gpsfarmguide/purchases/NavigatorBillingHandler;->mBillingClient:Lcom/android/billingclient/api/BillingClient;

    if-eqz v0, :cond_0

    invoke-virtual {v0, p0}, Lcom/android/billingclient/api/BillingClient;->startConnection(Lcom/android/billingclient/api/BillingClientStateListener;)V

    .line 32
    iput-boolean v1, p0, Llt/noframe/gpsfarmguide/purchases/NavigatorBillingHandler;->mConnecting:Z

    return-void

    :cond_0
    const-string v0, "mBillingClient"

    .line 31
    invoke-static {v0}, Lkotlin/jvm/internal/Intrinsics;->throwUninitializedPropertyAccessException(Ljava/lang/String;)V

    const/4 v0, 0x0

    throw v0
.end method

.method public final onDestroy()V
    .locals 2

    .line 43
    iget-object v0, p0, Llt/noframe/gpsfarmguide/purchases/NavigatorBillingHandler;->mBindToActivityCycle:Ljava/util/concurrent/atomic/AtomicBoolean;

    const/4 v1, 0x0

    invoke-virtual {v0, v1}, Ljava/util/concurrent/atomic/AtomicBoolean;->set(Z)V

    .line 44
    iget-object v0, p0, Llt/noframe/gpsfarmguide/purchases/NavigatorBillingHandler;->pendingRequests:Ljava/util/concurrent/ArrayBlockingQueue;

    invoke-virtual {v0}, Ljava/util/concurrent/ArrayBlockingQueue;->clear()V

    .line 47
    :try_start_0
    iget-object v0, p0, Llt/noframe/gpsfarmguide/purchases/NavigatorBillingHandler;->mBillingClient:Lcom/android/billingclient/api/BillingClient;

    if-eqz v0, :cond_0

    invoke-virtual {v0}, Lcom/android/billingclient/api/BillingClient;->endConnection()V

    goto :goto_0

    :cond_0
    const-string v0, "mBillingClient"

    invoke-static {v0}, Lkotlin/jvm/internal/Intrinsics;->throwUninitializedPropertyAccessException(Ljava/lang/String;)V
    :try_end_0
    .catch Ljava/lang/IllegalArgumentException; {:try_start_0 .. :try_end_0} :catch_0

    const/4 v0, 0x0

    throw v0

    :catch_0
    move-exception v0

    .line 49
    invoke-virtual {v0}, Ljava/lang/IllegalArgumentException;->printStackTrace()V

    .line 50
    invoke-static {v0}, Lcom/crashlytics/android/Crashlytics;->logException(Ljava/lang/Throwable;)V

    .line 52
    :goto_0
    iput-boolean v1, p0, Llt/noframe/gpsfarmguide/purchases/NavigatorBillingHandler;->mConnecting:Z

    return-void
.end method

.method public final onGetPurchasedItems(Ljava/util/List;)V
    .locals 6
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "(",
            "Ljava/util/List<",
            "+",
            "Lcom/android/billingclient/api/Purchase;",
            ">;)V"
        }
    .end annotation

    const-string v0, "purchases"

    invoke-static {p1, v0}, Lkotlin/jvm/internal/Intrinsics;->checkParameterIsNotNull(Ljava/lang/Object;Ljava/lang/String;)V

    .line 158
    invoke-interface {p1}, Ljava/lang/Iterable;->iterator()Ljava/util/Iterator;

    move-result-object p1

    const/4 v0, 0x0

    const/4 v1, 0x0

    :cond_0
    :goto_0
    invoke-interface {p1}, Ljava/util/Iterator;->hasNext()Z

    move-result v2

    const/4 v3, 0x1

    if-eqz v2, :cond_2

    invoke-interface {p1}, Ljava/util/Iterator;->next()Ljava/lang/Object;

    move-result-object v2

    check-cast v2, Lcom/android/billingclient/api/Purchase;

    .line 72
    new-instance v4, Ljava/lang/StringBuilder;

    invoke-direct {v4}, Ljava/lang/StringBuilder;-><init>()V

    const-string v5, "sent info for "

    invoke-virtual {v4, v5}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    invoke-virtual {v2}, Lcom/android/billingclient/api/Purchase;->getSku()Ljava/lang/String;

    move-result-object v5

    invoke-virtual {v4, v5}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    invoke-virtual {v4}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v4

    const-string v5, "FamBillingHelper"

    invoke-static {v5, v4}, Landroid/util/Log;->d(Ljava/lang/String;Ljava/lang/String;)I

    .line 74
    invoke-virtual {v2}, Lcom/android/billingclient/api/Purchase;->getSku()Ljava/lang/String;

    move-result-object v4

    const-string v5, "remove_ads_2"

    invoke-static {v4, v5}, Lkotlin/jvm/internal/Intrinsics;->areEqual(Ljava/lang/Object;Ljava/lang/Object;)Z

    move-result v4

    if-nez v4, :cond_1

    invoke-virtual {v2}, Lcom/android/billingclient/api/Purchase;->getSku()Ljava/lang/String;

    move-result-object v2

    const-string v4, "remove_ads"

    invoke-static {v2, v4}, Lkotlin/jvm/internal/Intrinsics;->areEqual(Ljava/lang/Object;Ljava/lang/Object;)Z

    move-result v2

    if-eqz v2, :cond_0

    :cond_1
    const/4 v1, 0x1

    goto :goto_0

    :cond_2
    if-eqz v1, :cond_3

    .line 80
    sget-object p1, Llt/noframe/gpsfarmguide/utils/Preferences;->ADS_REMOVED:Llt/minvib/magicpreferences/MagicBooleanPreference;

    iget-object v0, p0, Llt/noframe/gpsfarmguide/purchases/NavigatorBillingHandler;->activity:Llt/noframe/gpsfarmguide/views/ActivityDrawer;

    invoke-static {v3}, Ljava/lang/Boolean;->valueOf(Z)Ljava/lang/Boolean;

    move-result-object v1

    invoke-virtual {p1, v0, v1}, Llt/minvib/magicpreferences/MagicBooleanPreference;->set(Landroid/content/Context;Ljava/lang/Boolean;)V

    .line 81
    iget-object p1, p0, Llt/noframe/gpsfarmguide/purchases/NavigatorBillingHandler;->activity:Llt/noframe/gpsfarmguide/views/ActivityDrawer;

    invoke-virtual {p1}, Llt/noframe/gpsfarmguide/views/ActivityDrawer;->onAdsRemoved()V

    goto :goto_1

    .line 83
    :cond_3
    sget-object p1, Llt/noframe/gpsfarmguide/utils/Preferences;->ADS_REMOVED:Llt/minvib/magicpreferences/MagicBooleanPreference;

    iget-object v1, p0, Llt/noframe/gpsfarmguide/purchases/NavigatorBillingHandler;->activity:Llt/noframe/gpsfarmguide/views/ActivityDrawer;

    invoke-static {v0}, Ljava/lang/Boolean;->valueOf(Z)Ljava/lang/Boolean;

    move-result-object v0

    invoke-virtual {p1, v1, v0}, Llt/minvib/magicpreferences/MagicBooleanPreference;->set(Landroid/content/Context;Ljava/lang/Boolean;)V

    :goto_1
    return-void
.end method

.method public onPurchasesUpdated(ILjava/util/List;)V
    .locals 0
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "(I",
            "Ljava/util/List<",
            "Lcom/android/billingclient/api/Purchase;",
            ">;)V"
        }
    .end annotation

    if-eqz p2, :cond_0

    .line 57
    invoke-virtual {p0, p2}, Llt/noframe/gpsfarmguide/purchases/NavigatorBillingHandler;->onGetPurchasedItems(Ljava/util/List;)V

    goto :goto_0

    .line 59
    :cond_0
    new-instance p1, Llt/noframe/gpsfarmguide/purchases/NavigatorBillingHandler$onPurchasesUpdated$1;

    invoke-direct {p1, p0}, Llt/noframe/gpsfarmguide/purchases/NavigatorBillingHandler$onPurchasesUpdated$1;-><init>(Llt/noframe/gpsfarmguide/purchases/NavigatorBillingHandler;)V

    invoke-virtual {p0, p1}, Llt/noframe/gpsfarmguide/purchases/NavigatorBillingHandler;->getPurchasedItems(Lkotlin/jvm/functions/Function1;)V

    :goto_0
    return-void
.end method
